1 00:00:00,480 --> 00:00:00,740 All right. 2 00:00:00,750 --> 00:00:06,240 So now we're going to add a script to our barrel, which is going to turn on and off our zombie spawning. 3 00:00:06,240 --> 00:00:12,090 And I have a proximity prompt which is going to trigger an event which is going to make that happen. 4 00:00:12,090 --> 00:00:12,380 Right. 5 00:00:12,410 --> 00:00:13,590 We haven't hooked that up yet. 6 00:00:13,590 --> 00:00:15,210 We just have the action prompt here. 7 00:00:15,210 --> 00:00:16,740 That's a proximity prompt. 8 00:00:16,770 --> 00:00:23,550 I want to take a look at this, but before I do, I'm going to go down to server script service and 9 00:00:23,550 --> 00:00:29,190 I'm going to get my activated on the Z spotter and uncheck it. 10 00:00:29,190 --> 00:00:29,470 Right. 11 00:00:29,520 --> 00:00:33,060 We're going to start with it off right now. 12 00:00:33,060 --> 00:00:34,200 I'm going to play this. 13 00:00:34,200 --> 00:00:36,780 Take a look at my my action prompt. 14 00:00:38,850 --> 00:00:38,970 Yeah. 15 00:00:39,000 --> 00:00:39,430 There it is. 16 00:00:39,500 --> 00:00:43,800 Oh, I should have made my my spawn location closer to the barrel. 17 00:00:44,910 --> 00:00:45,300 There we go. 18 00:00:45,300 --> 00:00:47,640 We don't have very much gas coming out of there. 19 00:00:47,850 --> 00:00:49,840 So that is my proximity prompt. 20 00:00:49,860 --> 00:00:54,120 We can configure this to be a little bit more descriptive. 21 00:00:54,120 --> 00:00:56,070 So let's go ahead and turn us off. 22 00:00:56,820 --> 00:01:00,180 Go back to our action prompt under the barrel. 23 00:01:00,180 --> 00:01:08,160 So barrel lid top action prompt Change the action text to release. 24 00:01:09,620 --> 00:01:10,760 Valve. 25 00:01:14,770 --> 00:01:15,670 There we go. 26 00:01:15,700 --> 00:01:17,460 We should say turn release valve. 27 00:01:17,470 --> 00:01:21,640 Maybe I'll do turn release Valve because you never know which way to turn anything. 28 00:01:21,640 --> 00:01:22,140 Right. 29 00:01:22,150 --> 00:01:25,240 It's going to make the zombies come out or is it going to stop the zombies? 30 00:01:25,540 --> 00:01:26,170 Cool. 31 00:01:26,170 --> 00:01:28,480 And then I'm going to go down here a little bit. 32 00:01:28,480 --> 00:01:29,650 Four hole duration. 33 00:01:29,660 --> 00:01:30,820 I'll make it 2 seconds. 34 00:01:30,820 --> 00:01:32,920 You can make it 2 seconds or 5 seconds. 35 00:01:32,920 --> 00:01:35,410 You want it to be kind of stressful when they're trying to turn it off, right? 36 00:01:35,410 --> 00:01:39,850 Because the zombies are going to be running around and then max activation distance. 37 00:01:39,850 --> 00:01:40,960 That's good at ten. 38 00:01:41,350 --> 00:01:47,260 But I'm also going to turn off what is this line of sight? 39 00:01:47,260 --> 00:01:48,790 Where is our line of sight? 40 00:01:49,240 --> 00:01:50,080 There it is. 41 00:01:50,080 --> 00:01:51,550 Requires line of sight. 42 00:01:51,550 --> 00:01:55,300 I'm going to say no, because sometimes when you're building stuff, you get a part in a way. 43 00:01:55,300 --> 00:01:59,050 And that's frustrating if your character is trying to if your player is trying to stand in front of 44 00:01:59,050 --> 00:02:01,210 it to get the prompt to come up and it can't. 45 00:02:01,810 --> 00:02:02,080 All right. 46 00:02:02,080 --> 00:02:03,010 I think we're good. 47 00:02:03,220 --> 00:02:05,890 Let's go to our lid top. 48 00:02:06,870 --> 00:02:09,210 Hit the little plus sign there. 49 00:02:09,840 --> 00:02:10,860 I had the script. 50 00:02:12,000 --> 00:02:13,880 And then I'm going to call this action. 51 00:02:13,880 --> 00:02:16,730 Z Cool. 52 00:02:16,760 --> 00:02:19,040 We need a variable for our part. 53 00:02:19,160 --> 00:02:20,860 So that's a local part. 54 00:02:20,870 --> 00:02:22,400 That's the lid top, right? 55 00:02:22,400 --> 00:02:25,070 But I'm just going to call a part in case we want to move that script. 56 00:02:25,190 --> 00:02:26,990 So it's going to be script parent. 57 00:02:27,770 --> 00:02:31,040 I'm going to need my proximity prompt. 58 00:02:32,200 --> 00:02:34,730 I will just have prompt because we're only going to have one. 59 00:02:34,880 --> 00:02:36,380 So say part. 60 00:02:36,680 --> 00:02:43,400 We have a variable for the part, which is script parent and on the part we have a prompt and we call 61 00:02:43,400 --> 00:02:44,870 it action prompt. 62 00:02:45,530 --> 00:02:45,950 Cool. 63 00:02:46,220 --> 00:02:48,320 We need a sound to write. 64 00:02:49,250 --> 00:02:50,660 Let's call alarm. 65 00:02:51,230 --> 00:02:51,860 Alarm. 66 00:02:51,860 --> 00:02:53,270 We need alarm sound. 67 00:02:53,330 --> 00:02:58,370 It's going to start going off when we turn on the turn on the Z spanner. 68 00:02:58,400 --> 00:03:00,110 Let's go to our game here. 69 00:03:00,290 --> 00:03:02,300 Go to Toolbox. 70 00:03:03,420 --> 00:03:04,110 Click it. 71 00:03:05,020 --> 00:03:11,110 Models will go to audio and then under audio on a search for alarm. 72 00:03:12,740 --> 00:03:13,790 Ario. 73 00:03:14,090 --> 00:03:15,080 A nuclear arm. 74 00:03:16,250 --> 00:03:17,090 I like that. 75 00:03:17,960 --> 00:03:18,350 All right. 76 00:03:18,350 --> 00:03:22,460 I'm going to insert that click on the part you want to insert this into. 77 00:03:22,700 --> 00:03:25,450 I had lid top insert. 78 00:03:25,460 --> 00:03:26,600 It's going to pop in there. 79 00:03:26,600 --> 00:03:29,780 If it goes somewhere else, you can just drag it under the lid top. 80 00:03:30,180 --> 00:03:30,370 All right. 81 00:03:30,380 --> 00:03:31,340 I'm going to change his name. 82 00:03:31,340 --> 00:03:32,050 It's too long. 83 00:03:32,060 --> 00:03:33,380 I'm just going to call it alarm. 84 00:03:33,860 --> 00:03:34,400 There we go. 85 00:03:34,400 --> 00:03:35,120 Alarm. 86 00:03:35,840 --> 00:03:36,500 Cool. 87 00:03:36,530 --> 00:03:41,360 And I want to make sure it's looped in case it turns off before I'm ready for it to turn off. 88 00:03:41,360 --> 00:03:42,800 So we'll hit looped. 89 00:03:43,590 --> 00:03:46,580 And that way they'll just keep going until we actually say stop. 90 00:03:47,270 --> 00:03:47,510 All right. 91 00:03:47,510 --> 00:03:51,470 Now we go back here and on our part we have an alarm. 92 00:03:52,160 --> 00:03:53,000 There it is. 93 00:03:53,330 --> 00:03:54,290 What else do we need? 94 00:03:54,860 --> 00:03:59,510 We need this activated variable right here. 95 00:03:59,510 --> 00:04:03,000 And it is on my script, which is in server script service. 96 00:04:03,140 --> 00:04:04,430 Little bit inconvenient. 97 00:04:04,430 --> 00:04:09,440 So let's get a variable for server script service source because I'm lazy and we're not going to use 98 00:04:09,440 --> 00:04:09,950 it in the script. 99 00:04:09,950 --> 00:04:16,940 We're just going to get the activated, let's say game get service server, script service. 100 00:04:17,150 --> 00:04:17,780 Cool. 101 00:04:17,780 --> 00:04:22,550 And then when server script service, we're going to get our Z Spanner script because we still need 102 00:04:22,550 --> 00:04:24,320 a variable on that script. 103 00:04:24,530 --> 00:04:26,030 So say Spawn or Z. 104 00:04:26,030 --> 00:04:31,130 Spanner says, Wait for child Z spotter. 105 00:04:31,640 --> 00:04:31,970 All right. 106 00:04:31,970 --> 00:04:37,430 And then finally, this is what we need activated, right? 107 00:04:37,430 --> 00:04:38,930 That's on the Z spanner. 108 00:04:40,130 --> 00:04:41,660 We could just do activated. 109 00:04:41,660 --> 00:04:43,070 But I'm being cautious. 110 00:04:43,070 --> 00:04:45,530 We'll do wait for child activated. 111 00:04:46,610 --> 00:04:46,910 All right. 112 00:04:46,940 --> 00:04:53,660 We need a function to capture the proximity prompt event that triggered event. 113 00:04:53,660 --> 00:04:57,350 So I'm going to call this on release. 114 00:04:57,830 --> 00:04:58,300 Right. 115 00:04:58,340 --> 00:05:00,260 The player will get passed in. 116 00:05:00,260 --> 00:05:01,880 Let's go ahead and capture the event now. 117 00:05:01,880 --> 00:05:04,820 So go down to the bottom and then we're going to get this prompt. 118 00:05:04,940 --> 00:05:13,340 The triggered is the event that when you hold that thing down, it's going to fire connect on release, 119 00:05:13,340 --> 00:05:13,600 Right? 120 00:05:13,610 --> 00:05:16,340 So it's just like a button, really cool. 121 00:05:16,340 --> 00:05:18,260 But it pops up automatically when you get closed. 122 00:05:18,260 --> 00:05:19,280 That's convenient. 123 00:05:19,610 --> 00:05:19,910 All right. 124 00:05:19,910 --> 00:05:22,310 So now in the release, we triggered it. 125 00:05:22,310 --> 00:05:23,330 Two things can happen. 126 00:05:23,330 --> 00:05:25,340 We can either turn it on or we turn it off. 127 00:05:25,340 --> 00:05:32,990 So I'm going to say if activated, right, activate a value because it's a Boolean value, then we have 128 00:05:32,990 --> 00:05:33,590 to turn it off. 129 00:05:33,590 --> 00:05:34,760 It's already on. 130 00:05:34,760 --> 00:05:40,490 So I'm going to say activated dot value will be false. 131 00:05:40,490 --> 00:05:43,160 We're turning it off and there's going to be a sound playing right. 132 00:05:43,160 --> 00:05:44,660 There's going to be an alarm playing. 133 00:05:44,900 --> 00:05:46,640 So I'm going to say alarm. 134 00:05:46,640 --> 00:05:48,950 Colon, stop. 135 00:05:49,280 --> 00:05:49,610 Right. 136 00:05:49,610 --> 00:05:55,340 We haven't turned it on yet, but we will in a second because the other condition in the else right 137 00:05:55,340 --> 00:05:58,970 here is going to be the opposite. 138 00:05:58,970 --> 00:06:02,660 So let's say it is off now. 139 00:06:02,660 --> 00:06:06,200 Somebody turned the valve and it's on. 140 00:06:06,200 --> 00:06:06,740 Right. 141 00:06:06,740 --> 00:06:08,600 So the alarm is going to start playing. 142 00:06:08,600 --> 00:06:10,040 We'll say play. 143 00:06:11,280 --> 00:06:12,150 All right, cool. 144 00:06:12,180 --> 00:06:14,460 Now, the alarm won't start playing if we. 145 00:06:14,700 --> 00:06:16,410 If we go ahead and check this. 146 00:06:16,440 --> 00:06:17,400 Just keep that in mind. 147 00:06:17,400 --> 00:06:17,700 Right. 148 00:06:17,700 --> 00:06:23,460 So make sure it's off, because we'll have to turn the alarm off some on some other way if we have it 149 00:06:23,460 --> 00:06:26,550 as a default behavior for when the game starts. 150 00:06:26,550 --> 00:06:28,800 So you go walking up here, you're like, Oh, look at this. 151 00:06:29,520 --> 00:06:31,230 There's a little bit of green gas in here. 152 00:06:31,230 --> 00:06:34,350 We could actually increase that, right says turn release valve. 153 00:06:34,350 --> 00:06:35,970 Oh, yeah, probably should. 154 00:06:37,760 --> 00:06:38,680 Oh, man. 155 00:06:38,690 --> 00:06:39,560 What's that sound? 156 00:06:40,160 --> 00:06:41,240 That doesn't sound good. 157 00:06:42,300 --> 00:06:43,560 Oh, zombies. 158 00:06:43,860 --> 00:06:47,250 Let me run and run away. 159 00:06:49,530 --> 00:06:50,050 I want to get. 160 00:06:50,070 --> 00:06:51,810 I want to get him underneath that boulder trap. 161 00:06:52,800 --> 00:06:57,540 Because another thing we're going to have to start doing, it's figuring out how to get points for their 162 00:06:57,540 --> 00:06:58,530 deaths. 163 00:06:58,680 --> 00:06:59,040 Right. 164 00:06:59,070 --> 00:07:03,870 So that's coming up to, oh, you know what I want to do in the next video? 165 00:07:03,870 --> 00:07:09,240 I'm going to add stickers to this to decals, because that can be a little bit tricky and people like 166 00:07:09,240 --> 00:07:10,170 to add decals. 167 00:07:10,170 --> 00:07:12,600 So I will see you in the next video.